//#########################################################################
//                              WackiEngie
//           Copyright (c) 2014 Marc Wacker. All rights reserved.
//#########################################################################

#include "WeUtilPrerequisites.h"
#include "WeEvent.h"
#include "WeTimer.h"

using namespace WackiEngine;

// yea this isn't really a proper unit test but they might be added sometimes

struct X
{
	void memFunction(int32 a)
	{
		std::cout << "CALL X::memFunction(" << a << "); of instance: " << (this) << std::endl;
	}
};

class Y
{
public:
	void memFunction(int32 a)
	{
		std::cout << "CALL Y::memFunction(" << a << "); of instance: " << (this) << std::endl;
	}

	static void staticMemFunction(int32 a)
	{
		std::cout << "CALL Y::staticMemFunction(" << a << ");" << std::endl;
	}
};

namespace foo
{
	void function(int32 a)
	{
		std::cout << "CALL foo::function(" << a << "); " << std::endl;
	}

	void complexFunction(int32 a, double b, String& c)
	{
		std::cout << "CALL foo::complexFunction(" << a << ", " << b << ", " << c << ");" << std::endl;
	}
	
}




int main()
{
	X x;
	Y y;

	Event<void(int32)> myEvent;
	Event<void(int32, double, String&)> myComplexEvent;

	EventHandle connection1;

	// connect the events
	connection1 = myEvent.connect(&foo::function);
	myEvent.connect(&x, &X::memFunction);
	myEvent.connect(&y, &Y::memFunction);
	myEvent.connect(&Y::staticMemFunction);

	myComplexEvent.connect(&foo::complexFunction);

	// trigger events
	myEvent(13);
	myComplexEvent(12, 14.23123, String("herro"));

	// disconnect one function
	connection1.disconnect();

	// trigger myEvent again
	myEvent(12);
	
}

